package com.study.gank.mvp.model

import com.study.gank.api.GankApi
import com.study.gank.bean.BaseResult
import com.study.gank.bean.GankGoods
import com.study.gank.mvp.contract.GankGoodsContract
import com.study.gank.ui.fragment.AndroidFragment
import com.study.gank.ui.fragment.GirlFragment
import com.study.gank.ui.fragment.IOSFragment
import io.reactivex.Observable
import javax.inject.Inject

class GankModel @Inject constructor(private val gankApi: GankApi) : GankGoodsContract.Model {
    override fun getData(page: Int, type: String): Observable<BaseResult<List<GankGoods>>> {
        return when (type) {
            AndroidFragment.ANDROID -> gankApi.getAndroidData(page)
            IOSFragment.IOS -> gankApi.getiOSData(page)
            GirlFragment.GIRL -> gankApi.getGirlData(page)
            else -> gankApi.getAndroidData(page)
        }
    }

}